home *** CD-ROM | disk | FTP | other *** search
- ;*******************************************************************************
- ;*
- ;* AEx1.s
- ;* © Simon Callan, 1992
- ;*
- ;* This program is intended as an example of using the Shared C Library from
- ;* assembler.
- ;*
- ;* int main(void)
- ;* {
- ;* printf("hello world\n");
- ;* return 0;
- ;* }
- ;*
- ;*******************************************************************************
-
- GET @.Header.Registers
-
- AREA |ASM$$Code|,CODE,READONLY
-
- EXPORT main
- IMPORT printf
- IMPORT |x$stack_overflow|
-
- main MOV ip,sp ; Generate APCS-R stack frame
- STMFD sp!,{fp,ip,lr,pc}
- SUB fp,ip,#4
-
- CMP sp,sl ; Have we reached the end of the stack (very unlikely at this point) ?
- BLLT |x$stack_overflow| ; Yes
-
- ADR a1,text ; a1 points to text
- BL printf ; call printf
-
- finished MOV a1,#0
- LDMEA fp,{fp,sp,pc}^
-
- text = "hello world",10,0
-
- END
-